package com.pactera.madp.cp.common.enums;

import com.pactera.madp.cp.service.impl.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;

@Getter
@AllArgsConstructor
@Slf4j
public enum BehaviorTrackEnum {

    MARKETING("marketing", BehaviorTrackMarketingServiceImpl.class),
    SHOPPING("shopping", BehaviorTrackShopingServiceImpl.class),
    LOST("lost", BehaviorTrackLostServiceImpl.class),
    UNTALK("untalk", BehaviorTrackUntalkServiceImpl.class),
    TASK("task", BehaviorTrackTaskServiceImpl.class),
    TODO("todo", BehaviorTrackTodoServiceImpl.class),
    CUSTOM_FORM("customFrom", BehaviorTrackCustomFormServiceImpl.class),
    PRODUCT("product", BehaviorTrackProductServiceImpl.class),
    DAILY_DATA("dailyData", BehaviorTrackDailyServiceImpl.class);


    private String type;

    private Class cls;

    public static BehaviorTrackEnum findByType(String type){
        Assert.notNull(type, "资源类型类型值不能为空!");
        for(BehaviorTrackEnum behaviorTrackEnum: values()){
            if(type.equals(behaviorTrackEnum.type)){
                return behaviorTrackEnum;
            }
        }

        throw new IllegalArgumentException("参数异常,参数值不在允许的值范围之内!");
    }
}
